<!DOCTYPE html>
<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>华猫商城</title>
		<style></style>
		<link href="../css/jquery.validator.css" rel="stylesheet">
		<link href="../css/common.css" rel="stylesheet">

		<link href="../plugin/userLib/css/user.css" rel="stylesheet">
		<link href="../plugin/userLib/css/userinfo.css" rel="stylesheet">
		<link href="../plugin/userLib/css/my_user.css" rel="stylesheet">
		<link href="../css/base.css" rel="stylesheet">
		<style>
			.n-default .n-left,
			.n-default .n-right {
				margin-top: 32px!important;
			}
		</style>
	</head>

	<body>
		<div id="header"></div>
		<div id="headerBox"></div>
		<!--<div id="nav_menu"></div>-->
		<div class="ZZHT-wrap">
			<div class="ZZHT-header" style="border-bottom: 1px solid #ffffff;">
				<div class="ZZHT-shop-nav">
					<div class="ZZHT-nav-box">
						<a href="#">
							<li class="liselect ZZHT-lfloat ZZHT-nav-boxa">用户中心</li>
						</a>
						<div class="ZZHT-clear"></div>
					</div>
				</div>
				<div class="ZZHT-clear"></div>
			</div>
			<div class="ZZHT-main">
				<div id="onLine_left"></div>
				<div class="ZZHT-content">

					<div class="ZZHT-user-head clearfix">
						<b>申请积分</b>
						<span class="user_bread fr">
        当前位置：<span>首页</span>--<span>申请积分</span>
						</span>
					</div>
					<div class="mains bz">
						<form action="#" id="buyScore" class="nice-validator n-default" novalidate="novalidate">
							<div class="form-group">
								<label class="control-label"><span class="text-label">购买金额：</span><input id="buyMoney" name="buyMoney" onkeydown="javascript:ZZHT.isNumberdote(this)" type="text" class="ipt" aria-required="true"></label>
							</div>
							<div class="form-group">
								<label class="control-label"><span class="text-label">获得积分：</span><span id="sumScore" class="ZZHT-fred">&nbsp;0</span></label>
							</div>
							<button id="subMitButton" class="sure_btn confirm_pay">确认</button>
						</form>
					</div>

				</div>
			</div>
			<div style="clear:both;"></div>
			<br>
		</div>
		<div id="ck3"></div>
		<script src="../js/jquery.min.js"></script>
		<script src="../js/jquery.validator.js"></script>
		<script src="../js/zh-CN.js"></script>
		<script src="../js/common.js"></script>
		<script src="../js/common_view.js"></script>
		<script src="../plugin/layer/layer.js"></script>
		<script src="../js/findPass.js"></script>
		<script type="text/javascript" src="../js/ljf_base.js"></script>
		<script type="text/javascript" src="../plugin/userLib/js/score.js"></script>
		<script type="text/javascript">
			var num;//兑换比例
			var shopId;//店铺id;
			$.get(SURL+'sktShops/findByUserId', {userId:localStorage.userId}, function (data, textStatus) {//获取店铺id
                shopId = data.entity[0].shopId;
				$.get(SURL+'webAccount/applyStockBefore',{},function(data){//获取兑换比例
					console.log(data.message);
					num = data.message;
	        		buyScore();
		       });
			});
			
			//申请积分
			function buyScore() {
			    $('#buyScore').validator({
			        rules: {
			            checkPrice: function(element) {
			                return /^\d+(\.\d{1,2})?$/.test(element.value) || '价格小数后长度必须在1-2位之内'
			            }
			        },
			        fields: {
			            'buyMoney':'购买金额:required;checkPrice'
			        },
			        valid: function(form) {
			            var params = new Object();
			            params['cash'] = $('#buyMoney').val();
			            params['shopId'] = shopId;
			            $("#subMitButton").html('正在提交...').attr('disabled', true);
			            $.get(SURL+'webAccount/isBuyTime', params, function(data, textStatus) {
			            	console.log(data);
			               	if(data.messageCode=="200"){
			               		var v = data.entity;
			               		var payData = JSON.stringify(data.entity);
			               		localStorage.payData = payData;
								location.href="../carts/checkout_grade.html?orderId="+v.orderId+'&money='+params['cash']+'&path=webAccount/buyStockScoreAfter';
			               	}else{
			               		layer.msg(data.message);
			               	}
			                $("#subMitButton").html('确认').attr('disabled', false);
			            });
			        }
			    });
			}
		</script>
	</body>

</html>